import {Dimensions, Platform, PixelRatio} from 'react-native'
const {width,height } = Dimensions.get('window');
const cellWidth = (width - 20) / 2 - 6;
let fontScale = PixelRatio.getFontScale();    //返回字体大小缩放比例
let pixelRatio = PixelRatio.get();      //当前设备的像素密度
const defaultPixel = 2;      
//px转换成dp                     //iphone6的像素密度
const w2 = 750 / defaultPixel;
const h2 = 1334 / defaultPixel;
const scale = Math.min(height / h2, width / w2);   //获取缩放比例
// alert(width)
export  function px2dp(uiElementPx) {
  return uiElementPx * width / 750;
}

// 代表在iphone5一样的小屏幕手机
export function iphone5(){
    if(width<=320){
        return true
    }
}
// 字体
export function setSpText(size) {
    if(pixelRatio<=2){//小手机
        size = Math.round((size * scale+0.5))-3;
    }
    return size / defaultPixel;
}

export function setHW(size) {
    if(pixelRatio<=2){//小手机
        size = Math.round((size * scale+0.5))-1;
    }
    return Math.ceil(size / defaultPixel);
}
